package xu.ye.view.adapter;

import java.util.List;

import com.agent.crm.view.R;

import xu.ye.bean.TypeBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class ContactTypeAdapter extends BaseAdapter{
    private Context ctx;
    private List<TypeBean> list;
    private LayoutInflater inflater;
    
    public ContactTypeAdapter(Context ctx, List<TypeBean> list){
        this.ctx = ctx;
        this.list = list;
        this.inflater = LayoutInflater.from(ctx);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.type_item, null);
            holder = new ViewHolder();
            holder.typeId = (TextView) convertView.findViewById(R.id.selectTypeId);
            holder.typename = (TextView) convertView.findViewById(R.id.typeNameId);
            holder.sysConfig = (TextView) convertView.findViewById(R.id.typeSysConfigId);
            convertView.setTag(holder);
        } else{
            holder = (ViewHolder) convertView.getTag();
        }
        TypeBean tb = list.get(position);
        holder.typeId.setText(tb.getTypeId() + "");
        holder.typename.setText(tb.getTypeName());
        holder.sysConfig.setText(tb.getSysConfig() + "");
        return convertView;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    
    private static class ViewHolder {
        TextView typeId;
        TextView typename;
        TextView sysConfig;
        
    }
    
}
